﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GGGK.Film.Comm
{
    public static class Extensions
    {
        /// <summary>
        /// 判断字符是否为空或null
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool IsEmptyOrNull(this string str)
        {
            if (string.IsNullOrEmpty(str)) return true;
            else return false;
        }

        /// <summary>
        /// string转int
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int ToInt(this string str)
        {
            if(int.TryParse(str, out int result))
                return result;
            else
                return 0;
        }

        /// <summary>
        /// string转double
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static double ToDouble(this string str)
        {
            if (double.TryParse(str, out double result))
                return result;
            else
                return 0;
        }


    }
}
